package com.atguigu.sparkcore.day01.singlevalue

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * Author atguigu
 * Date 2020/10/27 14:27
 */
object FlatMapDemo {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf().setAppName("FlatMapDemo").setMaster("local[2]")
        val sc: SparkContext = new SparkContext(conf)
        val list1 = List("abc", "aaa", "ccc")
        val rdd1= sc.parallelize(list1, 2)
        //val rdd2 = rdd1.flatMap(x => Array(x, x * x , x * x * x))
        val rdd2 = rdd1.flatMap(x => x)
        rdd2.collect().foreach(println)
        sc.stop()
        
    }
}
